// Decompiled by Jad v1.5.8e. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.geocities.com/kpdus/jad.html
// Decompiler options: packimports(3) 
// Source File Name:   AdvancedSchedulerDialog.java

package presenter;

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

// Referenced classes of package presenter:
//            FontChooser, BackgroundChooser, VideoChooser, ScriptureChooser, 
//            SongFile, Scheduler, Bible

public class AdvancedSchedulerDialog extends JFrame
    implements WindowListener, ActionListener
{

    public AdvancedSchedulerDialog(Scheduler scheduler, Bible bible)
    {
        schedule = new JPanel(new BorderLayout());
        this.scheduler = scheduler;
        clone = scheduler.clone();
        sched = clone.getContentPane();
        sched.requestFocusInWindow();
        schedule.add(sched, "West");
        boxes = new JPanel();
        vid = new JCheckBox("Video");
        back = new JCheckBox("Background");
        bib = new JCheckBox("Bible Verse");
        boxes.add(back);
        boxes.add(vid);
        boxes.add(bib);
        back.addActionListener(this);
        vid.addActionListener(this);
        bib.addActionListener(this);
        schedule.add(boxes, "North");
        choosers = new JPanel(new GridLayout(4, 1));
        fontChooser = new FontChooser();
        choosers.add(fontChooser);
        schedule.add(choosers, "Center");
        backgroundChooser = new BackgroundChooser();
        videoChooser = new VideoChooser();
        bibleChooser = new ScriptureChooser(bible);
        setContentPane(schedule);
        setSize(800, 600);
        time = new Timer(100, this);
        time.start();
        current = new SongFile();
        addWindowListener(this);
        this.bible = bible;
        setVisible(true);
    }

    public void windowOpened(WindowEvent windowevent)
    {
    }

    public void windowClosing(WindowEvent windowevent)
    {
    }

    public void windowClosed(WindowEvent e)
    {
        scheduler.setSchedule(clone.getSchedule());
        dispose();
    }

    public void windowIconified(WindowEvent windowevent)
    {
    }

    public void windowDeiconified(WindowEvent windowevent)
    {
    }

    public void windowActivated(WindowEvent windowevent)
    {
    }

    public void windowDeactivated(WindowEvent windowevent)
    {
    }

    public void actionPerformed(ActionEvent e)
    {
        SongFile sf = clone.getActive();
        if(sf == null)
            return;
        if(current != null && sf.getNumber() != current.getNumber())
        {
            choosers.remove(fontChooser);
            fontChooser = new FontChooser(sf);
            choosers.add(fontChooser);
            if(current.hasCustomBackground())
            {
                choosers.remove(backgroundChooser);
                backgroundChooser = new BackgroundChooser();
            }
            if(current.hasVideo())
            {
                choosers.remove(videoChooser);
                videoChooser = new VideoChooser();
            }
            if(current.hasCustomBackground() && current.getBackground() == null)
                current.setHasBackground(false);
            if(current.hasVideo() && current.getVideo() == null)
                current.setHasVideo(false);
            setContentPane(schedule);
            if(sf.hasCustomBackground())
            {
                back.setSelected(true);
                backgroundChooser.setSong(sf);
                backgroundChooser.setBackground(sf.getBackground());
                choosers.add(backgroundChooser);
            }
            if(sf.hasVideo())
            {
                vid.setSelected(true);
                videoChooser.setSong(sf);
                choosers.add(videoChooser);
            }
            if(!sf.isScripture());
        }
        current = sf;
        if(e.getSource() == back)
        {
            if(!sf.hasCustomBackground())
            {
                backgroundChooser = new BackgroundChooser();
                choosers.add(backgroundChooser);
                backgroundChooser.setSong(sf);
                sf.setHasBackground(true);
            } else
            {
                sf.setHasBackground(false);
                choosers.remove(backgroundChooser);
            }
        } else
        if(e.getSource() == vid)
        {
            if(!sf.hasVideo())
            {
                videoChooser = new VideoChooser();
                videoChooser.setSong(sf);
                sf.setHasVideo(true);
                choosers.add(videoChooser, "Center");
            } else
            {
                sf.setHasVideo(false);
                choosers.remove(videoChooser);
            }
        } else
        if(e.getSource() == bib)
            if(!sf.isScripture())
            {
                sf.setScripture(true);
                choosers.add(bibleChooser);
                bibleChooser.setSong(sf);
            } else
            {
                sf.setScripture(false);
                choosers.remove(bibleChooser);
            }
        bib.setSelected(sf.isScripture());
        vid.setSelected(sf.hasVideo());
        back.setSelected(sf.hasCustomBackground());
        if(e.getSource() != time || backgroundChooser.isUpdated() || videoChooser.isUpdated())
            setContentPane(schedule);
    }

    JPanel schedule;
    JPanel choices;
    JPanel videoChoose;
    JPanel background;
    Bible bible;
    JCheckBox vid;
    JCheckBox back;
    JCheckBox bib;
    JPanel boxes;
    Scheduler scheduler;
    Container sched;
    Timer time;
    SongFile current;
    BackgroundChooser backgroundChooser;
    VideoChooser videoChooser;
    ScriptureChooser bibleChooser;
    Scheduler clone;
    JPanel choosers;
    FontChooser fontChooser;
}
